#include <stdio.h>
#include <windows.h>

int Add(int a, int b)
{
    return a + b;
}

int Sub(int a, int b)
{
    return a - b;
}

int Mul(int a, int b)
{
    return a * b;
}

int Div(int a, int b)
{
    return a / b;
}

void menu()
{
    printf("0.退出;1.加法;2.减法;3.乘法;4.除法\n");
    printf("请选择：");
}

int main()
{
    int input = 0, a = 0, b = 0;
    int (*pf[5])(int, int) = {0, Add, Sub, Mul, Div};
    do
    {
        menu();
        scanf("%d", &input);
        if(input == 0)
        printf("退出！");
        else if(input < 0||input > 4)
        {
            printf("输入错误,请重新输入！");
            system("pause");
            continue;
        }
        else
        {
            printf("请输入两个操作数:");
            scanf("%d %d", &a, &b);
            printf("结果是:%d\n\n", pf[input](a, b));
        }
    } while (input);
    
    return 0;
}